<?php

//checks to see if username exists
//if it doesnt add a row to the users table

	include("config.php");

	$query="insert into USER values('','" . $_POST['username'] . "','" . $_POST['password1'] . "','" . $_POST['firstname'] . "','" . $_POST['surname'] . "','" . $_POST['address1'] . "','" . $_POST['address2'] . "','" . $_POST['city'] . "','" . $_POST['state1'] . "','" . $_POST['country'] . "','" . $_POST['postcode'] . "','" . $_POST['email'] . "')";
	
	if($_POST['username'] != '')
	{
		$qry = "SELECT * FROM USER WHERE USERNAME='" . $_POST['username'] . "'";// or die($qry);
		$rs=$dbrs;
		$rs = mysql_query($qry);

		if($rs) {
			if(mysql_num_rows($rs) > 0) {
				echo "<success>taken</success>";
			}
			else {
				$rs=mysql_query($query, $conn) or die("<success>Sql execution unsuccessful..." . mysql_error() . "</success>");
				echo "<success>success</success>";
			}
			@mysql_free_result($result);
		}
		else {
			echo "<success>Query failed</success>";
			die("Query failed");
		}
	}

?>

